home *** CD-ROM | disk | FTP | other *** search
- Path: erich.triumf.ca!bennett
- From: bennett@erich.triumf.ca (P.Bennett)
- Newsgroups: comp.lang.c
- Subject: Re: Crash Proofing?
- Date: 9 Mar 1996 16:15 PST
- Organization: TRIUMF: Tri-University Meson Facility
- Distribution: world
- Message-ID: <9MAR199616155785@erich.triumf.ca>
- References: <4hsfje$rbr@uwm.edu>
- NNTP-Posting-Host: ftp.triumf.ca
- News-Software: VAX/VMS VNEWS 1.50
-
- In article <4hsfje$rbr@uwm.edu>, peterk@alpha2.csd.uwm.edu (Peter J Kleczka) writes...
- ....
- > The program I'm working on (below) works fine as long
- >as the user enters an integer.....but it gets caught in an
- >endless loop between the functions: firstmenu() and firstchoice()
- >when I enter, say, 5.5 instead of an integer
-
- snip,snip...
-
- >unsigned choice;
- >
- >scanf ("%d", &choice);
-
- Don't use scanf() for user input - use fgets() instead, then you can use
- sscanf(), atoi(), and other functions to process the input, and can check
- for, and reject, bad input.
-
- Peter Bennett VE7CEI | Vessels shall be deemed to be in sight
- Internet: bennett@triumf.ca | of one another only when one can be
- Packet: ve7cei@ve7kit.#vanc.bc.ca | observed visually from the other
- TRIUMF, Vancouver, B.C., Canada | ColRegs 3(k)
- GPS and NMEA info and programs: ftp://sundae.triumf.ca/pub/peter/index.html
- or: ftp://ftp-i2.informatik.rwth-aachen.de/pub/arnd/GPS/peter/index.html
-
-
-
-
-
-
-
-